/**
 * Copyright (C), 2001-2031, www.bosssof.com.cn
 * FileName: BaseMessage.java
 * Author: ckj
 * Date: 2024/7/21 下午9:46
 * Description:
 * 用于客户端与服务端传输的协议
 * History:
 * Date          Author   Version  Desc
 * 2024-01-01    bosssoft  1.0.0   initialize this file
 */
package com.bosssoft.message;

import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.List;


/**
 * @author ckj
 */
public abstract class BaseMessage {
    private Integer type;
    private List<String> content;
    private List<String> header;

    public abstract BaseMessage parse(BufferedReader reader, Integer type) throws Exception;
    /**
     *
     * @author ckj
     * @date 2024/07/22 下午10:43
     * 将对象中的复杂数据结构以一种统一的、可传输或可处理的字符串列表形式
     * @return java.util.List<java.lang.String>
     */
    public List<String> convertFromTransferableDataList() {
        List<String> list = new ArrayList<>();

        list.add(String.valueOf(getType()));
        list.addAll(getHeader());
        list.add(String.valueOf(getContent().size()));
        list.addAll(getContent());

        return list;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public List<String> getContent() {
        return content;
    }

    public void setContent(List<String> content) {
        this.content = content;
    }

    public List<String> getHeader() {
        return header;
    }

    public void setHeader(List<String> header) {
        this.header = header;
    }
}